package com.myway.dto.base.domain;

import java.util.HashMap;

/**
 * 类名称：Client <br/>
 * 类描述：客户端列表,对客户端而言,规范其传入参数,服务端作为校验的依据 <br/>
 * 创建时间：2016年1月11日 下午12:53:33 <br/>
 * @author 张涛
 * @version V1.0
 */
public enum Client {
	
	B2C("B2C"),			//B2C
	CallCenter("CC"),	//呼叫中心
	WeChat("WC"),		//微信端
	CLK("CLK"),			//常旅客
	YH("YH"),  			//一嗨
	FARE("FARE"), 		//运价
	ESB("ESB");			//ESB
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, Client> map;
	
	/**
	 * Construct the hash map at load time
	 */
	static 
	{
		map = new HashMap<String, Client>();
		for (Client type : Client.values()) {
			map.put(type.alias, type);
		}
		
	}

	Client(String alias) 
	{
		this.alias = alias;
	}

	@Override
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>Action</code> object holding the value of specified alias name
	 *
	 * @param alias
	 *            the alias name of the type
	 *
	 * @return a <code>Action</code> object holding the value represented by the alias name
	 *         argument
	 */
	public static Client valueOfAlias(String alias) 
	{
		Client type = map.get(alias);

		if (type == null) {
			throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias() {
		return this.alias;
	}
	
	
	
}
